package Ventanas;
import javax.swing.DefaultListModel;
import javax.swing.JDialog;
import javax.swing.JTree;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.UIManager;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.DefaultMutableTreeNode;

/**
 * Aqui queda un mundo todavia.
 * @author Javi
 *
 */
public class VAdminTemas extends JDialog{
	
	private DefaultListModel dlm;
	private JList lista;
	private JScrollPane panelArbolTemas;
	private JTree arbolTemas;
	private JButton botonModerar;
	private JButton botonDejarDeModerar;
	private JLabel lblJerarquiaDelForo;
	private JScrollPane panelTemasModerados;

	/**
	 * Launch the  application.
	 */
	public static void main(String[] args) {
				try {
					VAdminTemas window = new VAdminTemas();
					window.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
	}

	/**
	 * Create the application.
	 */
	public VAdminTemas() {
		try
		{
		   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (Exception e)
		{
		   e.printStackTrace();
		}
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		setBounds(100, 100, 488, 457);
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		getContentPane().setLayout(null);
		dlm = new DefaultListModel();
		
		panelArbolTemas = new JScrollPane();
		panelArbolTemas.setBounds(10, 34, 173, 374);
		getContentPane().add(panelArbolTemas);
		
		arbolTemas = new JTree();
		arbolTemas.setModel(new DefaultTreeModel(
			new DefaultMutableTreeNode("Indaltronia") {
				{
					DefaultMutableTreeNode node_1;
					node_1 = new DefaultMutableTreeNode("Informatica");
						node_1.add(new DefaultMutableTreeNode("Software"));
						node_1.add(new DefaultMutableTreeNode("Hardware"));
					add(node_1);
					node_1 = new DefaultMutableTreeNode("Cocina");
						node_1.add(new DefaultMutableTreeNode("Ollas"));
						node_1.add(new DefaultMutableTreeNode("Hornos"));
					add(node_1);
					node_1 = new DefaultMutableTreeNode("Electronica");
						node_1.add(new DefaultMutableTreeNode("Chinos baratos"));
						node_1.add(new DefaultMutableTreeNode("Alemanes wenos"));
					add(node_1);
					add(new DefaultMutableTreeNode("Cosas que pasan"));
					add(new DefaultMutableTreeNode("Linux"));
					
				}
			}
		));
		panelArbolTemas.setViewportView(arbolTemas);
		
		botonModerar = new JButton("Moderar ->");
		botonModerar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				dlm.addElement(arbolTemas.getSelectionModel().getLeadSelectionPath().getLastPathComponent());
			}
		});
		botonModerar.setBounds(193, 160, 89, 23);
		getContentPane().add(botonModerar);
		
		botonDejarDeModerar = new JButton("<html> &lt;- Dejar <p>de moderar</html> ");
		botonDejarDeModerar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (lista.getSelectedIndex() != -1)
			          dlm.removeElementAt(lista.getSelectedIndex());
			}
		});
		botonDejarDeModerar.setBounds(193, 194, 89, 37);
		getContentPane().add(botonDejarDeModerar);
		
		lblJerarquiaDelForo = new JLabel("Jerarqu\u00EDa del foro");
		lblJerarquiaDelForo.setBounds(10, 11, 119, 14);
		getContentPane().add(lblJerarquiaDelForo);
		
		panelTemasModerados = new JScrollPane();
		panelTemasModerados.setBounds(292, 34, 170, 374);
		getContentPane().add(panelTemasModerados);
		lista = new JList(dlm);
		panelTemasModerados.setViewportView(lista);
		setModal(true);
	}
}
